/// 环境变量
enum HttpEnv {
  /// 生产
  Production,

  /// 环境
  Test
}

/// 只做生命周期的内存存储
class BuildConfig {
  /// 工厂模式
  factory BuildConfig() => _getInstance();

  /// 单利
  static BuildConfig get shared => _getInstance();
  static BuildConfig? _instance;

  BuildConfig._internal();

  static BuildConfig _getInstance() {
    _instance ??= BuildConfig._internal();
    return _instance!;
  }

  /// 对应的环境模式
  HttpEnv _env = HttpEnv.Production;

  HttpEnv get env => _env;

  set env(HttpEnv env) {
    _env = env;
  }

  /// 获取主接口的地址
  String get getMainHostUrl {
    switch (env) {
      case HttpEnv.Production:
        return _getMainHostProduction;
      case HttpEnv.Test:
        return _getMainHostTest;
    }
  }

  /// 获取百度接口地址
  String get getBaiduPictureHostUrl => "https://image.baidu.com";

  /// 主接口的生产和测试地址
  String get _getMainHostProduction => "http://www.mockhttp.cn";

  String get _getMainHostTest => "http://www.mockhttp.cn";
}
